package com.guoranhao.tool.utils;

import org.apache.commons.lang.ClassUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Description:
 * Copyright (c) Department of Research and Development/Beijing
 * All Rights Reserved.
 *
 * @version 1.0 2018年06月20日 14:48 by 王广宇（wanggy@cloud-young.com）创建
 */
public class FileUtil {

    /**
     * @Description: 读取文件
     * @Version1.0 2018/3/27 16:41 by 王广宇 (wanggy@cloud-young.com) 创建
     * @param filePath
     * @return
     * @throws IOException
     */
    public static String getReadFile(String filePath) throws IOException {
        InputStream stream = ClassUtils.class.getClassLoader().getResourceAsStream(filePath);
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
        StringBuffer buffer = new StringBuffer();
        String text = null;
        while ((text = reader.readLine()) != null) {
            buffer.append(text);
        }
        return buffer.toString();
    }
}
